package com.baseproject.volley;

import java.util.concurrent.FutureTask;

/**
 * Created by hp on 2017/3/28.
 */

public class Volley {

    public static <T, M> void sendRequest(T requestInfo, String url, Class<M> response, IDataListener<M> dataListener) {
        //实例化一个请求结果处理类
        IHttpListener httpListener = new JSONHttpListener<>(response, dataListener);
        //实例化请求
        HttpTask httpTask = new HttpTask(requestInfo, url, httpListener);
        ThreadPoolManager.getInstance().execute(new FutureTask<Object>(httpTask, null));
    }
}

/**
 * 使用实例，目前RequestParamsCommodity设置未见效果，因此直接拼接请求string，并在返回结果string中过滤未实名认证的多余信息
 */
//Volley.sendRequest(new RequestParamsCommodity("getItemCommodityList"),
//        "http://1.taobaomyself.applinzi.com/?action=getItemCommodityList",
//        ResponseCommodity.class,
//        new IDataListener<ResponseCommodity>() {
//@Override
//public void onSuccess(ResponseCommodity responseCommodity) {
//        LogUtils.d(responseCommodity.toString());
//        }
//
//@Override
//public void onError() {
//        LogUtils.e("Volley error");
//        }
//        });
